<?php
/**
 * Created by PhpStorm.
 * User: Kiriti
 * Date: 2016/4/1 0001
 * Time: 14:57
 */

namespace app\controllers;

use yii\web\Controller;
use app\models\Rs_raised;
use app\models\Uc_user;
use app\models\Pr_support;
use Yii;

class PrsupportController extends Controller{
	
//    public $layout=false;
    public function actionShow(){


        if(!empty($_COOKIE['user_id'])){

            $user_id = $_COOKIE['user_id'];
            $user = Uc_user::find()
                ->where([
                    'user_id' => $user_id, //user_id => user_id
                    'del_flag' => 0
                ])
                ->one();
            $view = Yii::$app->view;
            $view->params['user_name'] = $user['user_name'];
            $view->params['field'] = $user['field'];
            $view->params['address'] = $user['address'];

            $view->params['like_num'] = "12";
            $view->params['invest_num'] = "13";
            $view->params['launch_num'] = "14";

            $query = Pr_support::find()
                ->where([
                    'user_id' => $user_id, //user_id => user_id
                    'del_flag' => 0
                ])->all();
            $inList = "";
            foreach($query as $key=>$id){
                $inList .= $id['raised_id'];
                $inList .= ",";
            }

            if($inList === ""){
                $inList .= -1;
            }else{
                $inList = substr($inList, 0, -1);
            }
            // echo $inList;
            $raised = Rs_raised::findBySql('SELECT * FROM rs_raised WHERE raised_id in ('. $inList.')')->all();
            return $this->render('prlike.php', ['raised'=>$raised]);

        }else{
            echo "<script>alert('cookie 不存在')</script>";
            sleep(3);
            $this->redirect(['login/show']);
        }

	}
}